package zeebe.export;

import io.zeebe.client.ZeebeClient;
import io.zeebe.client.api.response.DeploymentEvent;

import java.util.Arrays;
import java.util.List;

public class ExportDeploy {
    public static void main(String[] args) {
        System.out.println("创建Zeebe的连接");
        ZeebeClient client = ZeebeClient.newClientBuilder()
                .brokerContactPoint("localhost:26500")
                .usePlaintext()
                .build();

        System.out.println("部署工作流");
        String bpmnPath = "bpmn/exportDemo.bpmn";
        DeploymentEvent deployment = client.newDeployCommand()
                .addResourceFromClasspath(bpmnPath)
                .send()
                .join();

        System.out.println("部署exportJobWorker");
        List<String> param= Arrays.asList("NumberOne","NumberTwo");
        String inputType="calculate";
        CalculateJobWorkerHandler calculateJobWorkerHandler=new CalculateJobWorkerHandler(client);
        client.newWorker()
                .jobType(inputType)
                .handler(calculateJobWorkerHandler)
                .fetchVariables(param)
                .open();
    }
}
